function [FeaturesKNNTesting, Result] = Ddavid_MLkLNN_Testing(SampledTrueLabelTraining, SampledOnlyTrueLabelTraining, PriorProb, CondKNNTable, CondLabeledRanksTable, TrueLabelTesting, K, KL, TestingKNNList, LabeledTestingKNNList)

% [PriorProb, CondKNNTable, CondLabeledRanksTable] = Ddavid_MLkLNN_Training(SampledTrueLabelTraining, SampledOnlyTrueLabelTraining, K, KL, TrainingKNNList)
%
% <Input>
% SampledTrueLabelTraining: [n*k], the value is {-1, 1}, the sampled labels
%                                  of the training data, n is the number of
%                                  all training data, k is the number of
%                                  labels
% SampledOnlyTrueLabelTraining: [nl*k], the value is {-1, 1}, the sampled
%                                       labels of the labeled training data
%                                       , nl is the number of labeled data
%                                       , k is the number of labels
% K: The K value of KNN, K < n
% KL: The K value of KLNN, K < n
% TrainingKNNList: [n*(n-1)], The KNN List between training points and
%                             other training points (for saving time)
%
% <Output>

TestingSize = size(TrueLabelTesting, 1);
LabelSize = size(TrueLabelTesting, 2);

% Testing

FeaturesKNNTesting = zeros(TestingSize, LabelSize);

Result = ones(TestingSize, LabelSize);

for SizeCounter = 1:TestingSize
    
    %%% Get feature: KNN
    
    for KNNCounter = 1:K
        FeaturesKNNTesting(SizeCounter, :) = FeaturesKNNTesting(SizeCounter, :) + (SampledOnlyTrueLabelTraining(LabeledTestingKNNList(SizeCounter, KNNCounter), :) == 1);
    end
    
    %%% Calculate the result table
    
    Result(SizeCounter, :) = PriorProb;
    for LabelCounter = 1:LabelSize
        Result(SizeCounter, LabelCounter) = Result(SizeCounter, LabelCounter) * CondKNNTable(LabelCounter, FeaturesKNNTesting(SizeCounter, LabelCounter) + 1);
    end
end
